<?php

namespace App\V3\V3_2_7\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ImageLabelModel extends Model
{


    use HasFactory;

    protected $table   = 'image_label';

    static public function addImageLabel($data){

        return ImageLabelModel::insertGetId($data);
    }

    static public function getImageLabelList($condition,$sort_number,$currentPage,$pageSize){

        return  ImageLabelModel::select('*')->where($condition)
         ->where(function($query) use ($sort_number) {
             $query->orWhere('sort_number', 'like', '%'.$sort_number.'%');
         })
         ->orderBy('is_top', 'DESC')
        ->orderBy('sort_number', 'ASC')
        ->orderBy('create_time', 'ASC')
        ->paginate($pageSize,['*'], '',$currentPage)
        ->toArray();
    }
    static public function getImageLabelList02($condition){
        return  ImageLabelModel::select('id','content_tags','pa_id')->where($condition)
        ->orderBy('create_time', 'ASC')
        ->get()->toArray();
    }
    static public function updImageLabel($condition,$updData){

        return ImageLabelModel::where($condition)->update($updData);
    }

    static public function delImageLabel($condition){

        return ImageLabelModel::where($condition)->delete();
    }

    static public function getImageLabelInfo($condition){
        return ImageLabelModel::select('*')->where($condition)->first();
    }

    static public function getImageLabelLists($condition){

        return ImageLabelModel::select('*')->where($condition)
        ->orderBy('is_top', 'DESC')
        ->orderBy('sort_number', 'ASC')
        ->orderBy('create_time', 'ASC')
        ->get();
    }
}
